package com.ebupt.migu.music.autotri.controller;

import com.ebupt.migu.music.autotri.service.AutoOperateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author liuyangyang@e-byte.com
 * @description: 自动运营业务
 * 1、自动运营活动状态控制定时任务
 * 2、自动运营活动下发定时任务
 * initialDelay - 服务启动多长时间后执行任务（ms）
 * fixedRate - 上一次任务完成多久后执行下一次任务（ms）
 * @date 2023/6/25 16:34
 */
@Slf4j
@Component
@EnableScheduling
public class AutoOperateController {
    @Autowired
    private AutoOperateService autoOperateService;

    /**
     * 运营活动状态管控
     */
    @Scheduled(initialDelay = 1000 * 60, fixedRate = 1000 * 60)
    public void statusControl() {
        autoOperateService.statusControl();
    }

    /**
     * 清理REDIS临时客群
     */
    @Scheduled(initialDelay = 1000 * 60, fixedRate = 1000 * 60 * 60 * 12)
    public void cleanRedisTempKey() {
        autoOperateService.cleanRedisTempKey();
    }

    /**
     * 短信活动触发
     */
    @Scheduled(initialDelay = 1000 * 60, fixedRate = 1000 * 60 * 30)
    public void smsTrigger() {
        autoOperateService.smsTrigger();
    }

    /**
     * PUSH活动触发
     */
    @Scheduled(initialDelay = 1000, fixedRate = 1000 * 60 * 30)
    public void pushTrigger() {
        autoOperateService.pushTrigger();
    }

    /**
     * 消息通知活动触发
     */
    @Scheduled(initialDelay = 1000, fixedRate = 1000 * 60 * 10)
    public void messageTrigger() {
        autoOperateService.messageTrigger();
    }

    /**
     * 自动运营效果统计
     */
    @Scheduled(initialDelay = 1000, fixedRate = 1000 * 60 * 10)
    public void AutoOperationffectStatistics() {
        autoOperateService.autoOperationffectStatistics();
    }
}
